<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <input type="text" class="username">
    <br><br>
    <input type="password" class="userpwd">
    <br><br>
    <input type="text" class="usertel">
    <br><br>
    <button>注册</button>



    <script src="../js/tools.js"></script>
    <script>

        const oBtn = document.querySelector('button');
        const oUser = document.querySelector('.username');
        const oPwd = document.querySelector('.userpwd');
        const oTel = document.querySelector('.usertel');

        oBtn.onclick = function () {
            const username = oUser.value;
            const userpwd = oPwd.value;
            const usertel = oTel.value;
            if (username && userpwd && usertel) {
                ajax({
                    type : 'post' , 
                    path : '../php/reg.php' ,
                    // 简写！！！！！！！！！！！！！！！！！
                    data : {
                        username ,
                        userpwd , 
                        usertel 
                    } , 
                    success : res => {
                        console.log(res);
                        if(res.status) {
                            location.href = './03login.html' ;
                        } else {
                            alert(res.msg) ;
                        }
                    }
                })
            }
        }





    </script>

</body>

</html>